/**
 * Created by zhijie on 2016/12/15.
 */
/**
 * Created by hezhijie on 2016/11/22.
 */
var orderDetailModule = angular.module("orderDetail", []);
orderDetailModule.controller("orderDetailCtrl", ['$scope',
    function ($scope) {
        $scope.init = function () {
            $scope.getOrder();
        }

        $scope.getOrder = function () {
            if ($scope.$stateParams.id) {
                $post(basePath + "/rest/order/_get", {id: $scope.$stateParams.id}, function (result) {
                    $scope.order = result.resultValue;
                    $scope.$apply();
                })
            }
        }

        $scope.saveOrderDetail = function () {
            if ($scope.order.id) {
                $post(basePath + "/rest/order/_update", $scope.order, function (result) {
                    $scope.$state.go("home.content.order.orderList")
                })
            } else {
                $post(basePath + "/rest/order/_add", $scope.order, function (result) {
                    $scope.$state.go("home.content.order.orderList")
                })
            }
        }

        $scope.init();
    }
]);
